<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Trace="false"
    CodeFile="SprintTotals.aspx.cs" Inherits="SprintTotals" Title="Tackle - Sprint Totals" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentHolder" runat="Server">
    <strong>Sprint Totals<br />
        <br />
    </strong><span style="font-size: 8pt">This page shows the totals for each resource in
        a sprint.</span><br />
    <br />
    <asp:UpdatePanel runat="server" ID="UPGridView" UpdateMode="Conditional">
        <ContentTemplate>
<TABLE cellSpacing=0 cellPadding=4 width="98%"><TBODY><TR><TD style="BORDER-TOP: silver 1px ridge; BORDER-LEFT: silver 1px ridge; BORDER-BOTTOM: silver 1px ridge" vAlign=top bgColor=#e3eaeb><SPAN style="FONT-SIZE: x-small">Sprint:</SPAN> <asp:DropDownList id="ddSprintNames" runat="server" Font-Size="X-Small" OnSelectedIndexChanged="ddSprintNames_SelectedIndexChanged" DataValueField="SprintID" DataTextField="SprintName" DataSourceID="dsSprintNames" AutoPostBack="True" OnDataBound="ddSprintNames_DataBound">
                        </asp:DropDownList>&nbsp;<asp:ImageButton style="VERTICAL-ALIGN: middle" id="ibtnRefresh" onclick="btnRefresh_Click" runat="server" ToolTip="Click to Refresh the Product Backlog" ImageUrl="~/Images/Refresh.gif"></asp:ImageButton>&nbsp; </TD><TD style="BORDER-RIGHT: silver 1px ridge; BORDER-TOP: silver 1px ridge; BORDER-BOTTOM: silver 1px ridge; TEXT-ALIGN: right" vAlign=top bgColor=#e3eaeb><SPAN style="FONT-SIZE: x-small">Sprint Totals Thru:&nbsp;<asp:DropDownList id="ddSprintDateList" runat="server" Font-Size="X-Small" Font-Names="Verdana" ToolTip="View the sprint totals at a certain date." DataValueField="ValidDateValue" DataTextField="ValidDateValue" DataSourceID="dsGetSprintValidDates" AutoPostBack="True" DataTextFormatString="{0:d}"></asp:DropDownList> | Time Unit: <asp:DropDownList id="ddTimeUnits" runat="server" Font-Size="X-Small" Font-Names="Verdana" AutoPostBack="True">
                                <asp:ListItem Value="True">Hours</asp:ListItem>
                                <asp:ListItem Value="False">Days</asp:ListItem>
                            </asp:DropDownList></SPAN></TD></TR><TR><TD style="TEXT-ALIGN: left" vAlign=top colSpan=2>&nbsp;<BR /><asp:DetailsView id="dvSprintTotals" runat="server" ForeColor="#333333" Font-Size="X-Small" Font-Names="Verdana" BorderWidth="1px" BorderStyle="Ridge" BorderColor="Silver" DataSourceID="dsSprintTotalsData" Width="164px" Height="31px" GridLines="None" CellPadding="4" AutoGenerateRows="False">
                            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                            <CommandRowStyle BackColor="#C5BBAF" Font-Bold="True" />
                            <EditRowStyle BackColor="#7C6F57" />
                            <RowStyle BackColor="#E3EAEB" />
                            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                            <Fields>
                                <asp:BoundField DataField="TotalSprintTime" HeaderText="Total Sprint Time" ReadOnly="True"
                                    SortExpression="TotalSprintTime" />
                                <asp:BoundField DataField="CurrentSprintTime" HeaderText="Current Sprint Time" ReadOnly="True"
                                    SortExpression="CurrentSprintTime" />
                            </Fields>
                            <FieldHeaderStyle BackColor="#D0D0D0" Font-Bold="True" Width="120px" />
                            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                            <AlternatingRowStyle BackColor="White" />
                        </asp:DetailsView> &nbsp; &nbsp;</TD></TR><TR><TD vAlign=top colSpan=2><asp:GridView id="gvResourceInfo" runat="server" ForeColor="#333333" Font-Size="X-Small" Font-Names="Verdana" DataSourceID="dsSprintResource" Width="100%" GridLines="None" CellPadding="4" ShowFooter="True" OnRowDataBound="gvResourceInfo_RowDataBound" AutoGenerateColumns="False" AllowSorting="True">
                            <FooterStyle BackColor="#1C5E55" Font-Bold="False" ForeColor="White" />
                            <EmptyDataRowStyle ForeColor="Red" />
                            <Columns>
                                <asp:TemplateField HeaderText="Name" SortExpression="Person">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox16" runat="server" Text='<%# Bind("Person") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label16" runat="server" Text='<%# Bind("Person") %>' ToolTip="The name of the resource"></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Buffer" SortExpression="Buffer">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox15" runat="server" Text='<%# Bind("Buffer") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label15" runat="server" Text='<%# Bind("Buffer", "{0:F}") %>' ToolTip="The time buffer for the resource. The buffer is used to pad estimations of available time"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="OOF Time" SortExpression="OOFHours">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox14" runat="server" Text='<%# Bind("OOFHours") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label14" runat="server" Text='<%# Bind("OOFHours", "{0:F}") %>' ToolTip="The amount of time out of office for the resource during the sprint"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Avail Time" SortExpression="SprintHours">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("SprintHours") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("SprintHours", "{0:F}") %>' ToolTip="The available time in the sprint taking into account OOF, unbuffered tasks and the resources buffer"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Base Work" SortExpression="BaseLineHours">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("BaseLineHours") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("BaseLineHours", "{0:F}") %>' ToolTip="The baseline estimation of all tasks assigned to this resource"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Over Alloc" SortExpression="OverUnderBase">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("OverUnderBase") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("OverUnderBase", "{0:F}") %>' ToolTip="This number shows the amount of time the resource is scheduled over or under (if negative) versus the available amount of time in the sprint"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Work Comp" SortExpression="ActualWorkComp">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("ActualWorkComp") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("ActualWorkComp", "{0:F}") %>' ToolTip="The actual amount of work completed by the resource"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Work Rem" SortExpression="RemainingWork">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("RemainingWork") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label5" runat="server" Text='<%# Bind("RemainingWork", "{0:F}") %>' ToolTip="The amount of work remaining to be completed by the resource"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="OOF Rem" SortExpression="RemainingOOF">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("RemainingOOF") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label6" runat="server" Text='<%# Bind("RemainingOOF", "{0:F}") %>' ToolTip="The amount of out of office time still to be taken by the resource"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Time Rem" SortExpression="AvailHoursRemaining">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("AvailHoursRemaining") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label7" runat="server" Text='<%# Bind("AvailHoursRemaining", "{0:F}") %>' ToolTip="The total amount of time remaining in the sprint for the resource including today. Dependant upon OOF, unbuffered tasks and the resources buffer"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Ahead Behind" SortExpression="AheadBehindOnWork">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("AheadBehindOnWork") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label8" runat="server" Text='<%# Bind("AheadBehindOnWork", "{0:F}") %>' ToolTip="The amount of time ahead or behind (if negative) in the sprint for the resource. If there is 0.00 work remaining, this column will also be 0.00."></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Work Punted" SortExpression="PuntedWork">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("PuntedWork") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label9" runat="server" Text='<%# Bind("PuntedWork", "{0:F}") %>' ToolTip="The total amount of work punted by the resource in the sprint"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Actual OOF" SortExpression="ActualOOF">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox12" runat="server" Text='<%# Bind("ActualOOF") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label12" runat="server" Text='<%# Bind("ActualOOF", "{0:F}") %>' ToolTip="The actual amount of out of office taken during the sprint"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Planned Work" SortExpression="PlannedWorkComp">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox11" runat="server" Text='<%# Bind("PlannedWorkComp") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label11" runat="server" Text='<%# Bind("PlannedWorkComp", "{0:F}") %>' ToolTip="The amount of planned work completed in the sprint. Planned work is work completed but not declared as discovered"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Disc Work" SortExpression="DiscoveredWork">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox10" runat="server" Text='<%# Bind("DiscoveredWork") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label10" runat="server" Text='<%# Bind("DiscoveredWork", "{0:F}") %>' ToolTip="The amount of discovered work in the sprint for the resource"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="P vs. D Buffer" SortExpression="PlannedDiscBuffer">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox17" runat="server" Text='<%# Bind("PlannedDiscBuffer") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label17" runat="server" Text='<%# Bind("PlannedDiscBuffer", "{0:F}") %>'
                                            ToolTip="The calculated buffer for the resource based on planned versus discovered work"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Work Buffer" SortExpression="ActualBuffer">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox13" runat="server" Text='<%# Bind("ActualBuffer") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label13" runat="server" Text='<%# Bind("ActualBuffer", "{0:F}") %>' ToolTip="The calculated buffer for the resource based on current sprint time, actual OOF, planned work and discovered work"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle HorizontalAlign="Right" />
                                    <FooterStyle HorizontalAlign="Right" />
                                </asp:TemplateField>
                            </Columns>
                            <RowStyle BackColor="#E3EAEB" VerticalAlign="Top" />
                            <EditRowStyle BackColor="#7C6F57" />
                            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" HorizontalAlign="Left"
                                VerticalAlign="Top" />
                            <AlternatingRowStyle BackColor="White" />
                        </asp:GridView> <SPAN style="FONT-SIZE: x-small"><BR />Note: Hover over a value to get a detailed description of the column</SPAN></TD></TR></TBODY></TABLE>
</ContentTemplate>
    </asp:UpdatePanel>
    <asp:SqlDataSource ID="dsSprintNames" runat="server" ConnectionString="<%$ ConnectionStrings:TackleConnectionStringMain %>"
        SelectCommand="SELECT tblSprint.SprintID, tblMasterBacklogSchedule.SprintName FROM tblMasterBacklogSchedule INNER JOIN tblSprint ON tblMasterBacklogSchedule.MasterBacklogScheduleID = tblSprint.fMasterBacklogScheduleID WHERE (tblMasterBacklogSchedule.fScrumTeamID = @ScrumTeamID) ORDER BY tblMasterBacklogSchedule.EndDate DESC">
        <SelectParameters>
            <asp:SessionParameter Name="ScrumTeamID" SessionField="ScrumTeamID" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="dsSprintTotalsData" runat="server" ConnectionString="<%$ ConnectionStrings:TackleConnectionStringMain %>"
        ProviderName="<%$ ConnectionStrings:TackleConnectionStringMain.ProviderName %>"
        SelectCommand="GetSprintTotalsData" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddSprintNames" Name="SprintID" PropertyName="SelectedValue"
                Type="Int32" />
            <asp:ControlParameter ControlID="ddTimeUnits" Name="TimeUnitHours" PropertyName="SelectedValue"
                Type="Boolean" />
            <asp:ControlParameter ControlID="ddSprintDateList" Name="TimeThru" PropertyName="SelectedValue" Type="DateTime" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="dsSprintResource" runat="server" ConnectionString="<%$ ConnectionStrings:TackleConnectionStringMain %>"
        DeleteCommand="DELETE FROM tblSprintResources WHERE (SprintResourcesID = @original_SprintResourcesID)"
        InsertCommand="INSERT INTO tblSprintResources(fSprintID, Person, Buffer, OOFHours, CalculateSprintHours, AvailableSprintHours) VALUES (@SprintID,@Person,@Buffer,@OOFHours,@CalculateSprintHours,@AvailableSprintHours)"
        OldValuesParameterFormatString="original_{0}" SelectCommand="GetSprintTotalsForUser"
        SelectCommandType="StoredProcedure" UpdateCommand="UPDATE tblSprintResources SET Person = @Person, Buffer = @Buffer, OOFHours = @OOFHours, CalculateSprintHours = @CalculateSprintHours, AvailableSprintHours = @AvailableSprintHours WHERE (SprintResourcesID = @original_SprintResourcesID)">
        <DeleteParameters>
            <asp:Parameter Name="original_SprintResourcesID" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Person" />
            <asp:Parameter Name="Buffer" />
            <asp:Parameter Name="OOFHours" />
            <asp:Parameter Name="CalculateSprintHours" />
            <asp:Parameter Name="AvailableSprintHours" />
            <asp:Parameter Name="original_SprintResourcesID" />
        </UpdateParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="ddSprintNames" Name="SprintID" PropertyName="SelectedValue" />
            <asp:ControlParameter ControlID="ddTimeUnits" Name="TimeUnitHours" PropertyName="SelectedValue"
                Type="Boolean" />
            <asp:ControlParameter ControlID="ddSprintDateList" Name="TimeThru" PropertyName="SelectedValue"
                Type="DateTime" />
        </SelectParameters>
        <InsertParameters>
            <asp:ControlParameter ControlID="ddSprintSelection" Name="SprintID" PropertyName="SelectedValue" />
            <asp:Parameter Name="Person" />
            <asp:Parameter Name="Buffer" />
            <asp:Parameter Name="OOFHours" />
            <asp:Parameter Name="CalculateSprintHours" />
            <asp:Parameter Name="AvailableSprintHours" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="dsGetSprintValidDates" runat="server" ConnectionString="<%$ ConnectionStrings:TackleConnectionStringMain %>"
        ProviderName="<%$ ConnectionStrings:TackleConnectionStringMain.ProviderName %>"
        SelectCommand="GetValidSprintDatesForSprintTotals" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddSprintNames" Name="SprintID" PropertyName="SelectedValue"
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    &nbsp;&nbsp;
</asp:Content>
